﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Diagnostics;

namespace BYU_ECC {

    [TestFixture]
    public class KeyExperiments {
        private Stopwatch watch = new Stopwatch();
        private string results;

        [TestFixtureSetUp]
        public void Init() {
            results = "";
        }

        [TestFixtureTearDown]
        public void End() {
            Console.WriteLine("\nResults:\n" + results);
        }

        [SetUp]
        public void Start() {
            watch.Reset();
            watch.Start();
        }

        [TearDown]
        public void Stop() {
            watch.Stop();
            results += ","+watch.Elapsed.TotalSeconds+"\n";
            Console.WriteLine("Elapsed: " + watch.ElapsedMilliseconds + "ms / " + watch.Elapsed.TotalSeconds+"s");
        }

        [TestCase(KeySizeEnum.Size140)]
        [TestCase(KeySizeEnum.Size192)]
		[TestCase(KeySizeEnum.Size224)]
		[TestCase(KeySizeEnum.Size256)]
        [TestCase(KeySizeEnum.Size384)]
        [TestCase(KeySizeEnum.Size521)]
        /*[TestCase(KeySizeEnum.Size1024)]
        [TestCase(KeySizeEnum.Size2048)]
        [TestCase(KeySizeEnum.Size3072)]
        [TestCase(KeySizeEnum.Size7680)]*/
        [TestCase(KeySizeEnum.Size15360)]
        [Repeat(10)]
        public void TestRSAGenerationSpeed(KeySizeEnum keySize) {
            Console.Write("RSA at " + (int)keySize + ": ");
            results += "RSA" + (int)keySize;
            RSAAlgorithm.GenerateRSAAlgorithm(keySize);
        }

        [TestCase(KeySizeEnum.Size192)]
		[TestCase(KeySizeEnum.Size224)]
		[TestCase(KeySizeEnum.Size256)]
        [TestCase(KeySizeEnum.Size384)]
        [TestCase(KeySizeEnum.Size521)]
        [Repeat(10)]
        public void TestECCGenerationSpeed(KeySizeEnum keySize) {
            Console.Write("ECC at " + (int)keySize + ": ");
            results += "ECC" + (int)keySize;
            ParameterGenerator.GenerateTestParameters(keySize);
            KeyPairs.GenerateKeyPairs();
        }

    }
}
